Skip to content

introduce binding_exprt [blocks: #4510] #4931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2019
Merged

introduce binding_exprt [blocks: #4510] #4931

merged 3 commits into from
Aug 6, 2019

Conversation

kroening
Copy link
Member

This is a base class that factors out some common functionality of various
expressions that are variable bindings; examples are let, lambda, forall,
exists; future additions might include choose.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov-io
Copy link

codecov-io commented Jul 20, 2019

Codecov Report

Merging #4931 into develop will increase coverage by <.01%.
The diff coverage is 97.36%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4931      +/-   ##
===========================================
+ Coverage    69.24%   69.25%   +<.01%     
===========================================
  Files         1309     1309              
  Lines       108476   108499      +23     
===========================================
+ Hits         75117    75141      +24     
+ Misses       33359    33358       -1
Impacted Files Coverage Δ
src/ansi-c/expr2c_class.h 100% <ø> (ø) ⬆️
src/util/mathematical_expr.h 93.1% <100%> (+2.62%) ⬆️
src/ansi-c/c_typecheck_expr.cpp 72.55% <100%> (+0.02%) ⬆️
src/ansi-c/parser.y 78.08% <100%> (ø) ⬆️
src/solvers/smt2/smt2_parser.cpp 65.43% <100%> (ø) ⬆️
src/solvers/smt2/smt2_conv.cpp 59.62% <100%> (+0.03%) ⬆️
src/ansi-c/expr2c.cpp 67.13% <85.71%> (ø) ⬆️
.../goto-instrument/accelerate/acceleration_utils.cpp 0% <0%> (ø) ⬆️
src/solvers/flattening/boolbv_quantifier.cpp 91.89% <0%> (+0.11%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 602e2e8...190f1c8. Read the comment docs.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: ce8b26c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/119891946

@kroening kroening force-pushed the binding branch 2 times, most recently from 335fb5c to f13b9d7 Compare July 22, 2019 01:04
@kroening kroening requested a review from martin-cs as a code owner July 22, 2019 01:04
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't the users (e.g. typecheck_expr_main) use the newly-introduced interface instead of the pretty-opaque expr.op0().op0().op0()?

@@ -145,14 +140,14 @@ instantiate_quantifier(const quantifier_exprt &expr, const namespacet &ns)
return re;
}

const exprt min_i = get_quantifier_var_min(var_expr, re);
const exprt max_i = get_quantifier_var_max(var_expr, re);
const auto min_i = get_quantifier_var_min(var_expr, re);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use constant_exprt, nothing else here makes it obvious we're talking about a constant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These .op0() chains are very opaque and make it rather impossible to understand what's going on. And then wouldn't we really also need to make some changes in the back-end now that the structure of those expressions is different? And the commit message talks about lambdas, lets, but only quantifiers received this new treatment. I don't think we should do half-a-job here.

@tautschnig tautschnig changed the title introduce binding_exprt introduce binding_exprt [blocks: #4510] Aug 5, 2019
@kroening kroening force-pushed the binding branch 2 times, most recently from f4a41ab to 1895684 Compare August 5, 2019 13:56
@kroening kroening force-pushed the binding branch 2 times, most recently from 225d1cf to 4386617 Compare August 5, 2019 14:10
@kroening
Copy link
Member Author

kroening commented Aug 5, 2019

I've introduce further typing to reduce the op0() chains.
Note that we don't have lamba expressions yet, so this PR can't change them.

@tautschnig
Copy link
Collaborator

Note that we don't have lamba expressions yet, so this PR can't change them.

Well, we have array_comprehension_exprt (with id() == ID_lambda).

@kroening
Copy link
Member Author

kroening commented Aug 5, 2019

I'll clean up array_comprehension_exprt vs. Church's lamba_exprt in a follow-up PR; this should not be done here.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 190f1c8).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/121976290

@kroening kroening assigned tautschnig and unassigned kroening Aug 5, 2019

variablest &variables()
{
return (variablest &)static_cast<tuple_exprt &>(op0()).operands();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite likely this isn't the only such place, but this clearly makes USE_LIST no longer possible -- but in this case without causing compilation errors. So should we really get rid of USE_LIST right now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be possible to make this work with USE_LIST. Is USE_LIST sill useful?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code wouldn't actually compile with USE_LIST. If USE_LIST were to work, we could change irept to have only a single container and some cursor(s) into that. Whether that's more efficient or not I can't tell, because it wouldn't compile...

@tautschnig tautschnig assigned kroening and unassigned tautschnig Aug 5, 2019
This is a base class that factors out some common functionality of various
expressions that are variable bindings; examples are let, lambda, forall,
exists; future additions might include choose.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 3243b98).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/122132439
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Daniel Kroening added 2 commits August 6, 2019 19:01
This commit makes the quantifier base class use the bindings base class.
Methods and constructor for the special case of quantifying over one
variable are retained.
This clarifies that the expression returned by get_quantifier_var_min is a
constant -- request by @smowton.
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️
This PR failed Diffblue compatibility checks (cbmc commit: 0983a0c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/122168140
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 0983a0c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/122168140

@kroening kroening merged commit 9a3ffde into develop Aug 6, 2019
@kroening kroening deleted the binding branch August 6, 2019 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants